package correct.day15;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Test2 {
    public static int n, m;
    public static Map<Integer, Integer> hash = new HashMap<>(); // 统计每种声部的

    public static boolean check (int x) // 判断最多⼈数为 x 时，能否分成 m 组
    {
        int g = 0; // 统计能分成多少组
        for (int a : hash.values()) {
            g += a / x + (a % x == 0 ? 0 : 1);
        }
        return g <= m;
    }

    public static void main (String[]args)
    {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        int hmax = 0; // 所有声部的最⼤值
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            hash.put(x, hash.getOrDefault(x, 0) + 1);
            hmax = Math.max(hmax, hash.get(x));
        }

        // 边界情况
        int kinds = hash.size();
        if (kinds > m) {
            System.out.println(-1);
        } else {
             // 暴⼒解法
//             for(int i = 1; i <= hmax; i++)
//             {
//                 if(check(i))
//                 {
//                     System.out.println(i);
//                     break;
//                 }
//             }
            // ⼆分解法
            int l = 1, r = hmax;
            while (l < r) {
                int mid = (l + r) / 2;
                if (check(mid))
                    r = mid;
                else
                    l = mid + 1;
            }
            System.out.println(l);
        }
    }
}
